//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - SaaS Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================


//===============================================================================
// Microsoft Architecture Strategy Team
// LitwareHR - S+S Sample Application
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Windows;
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.SmartParts;
using Microsoft.Practices.CompositeUI.WPF;
using Microsoft.Practices.ObjectBuilder;

using LitwareHR.Infrastructure.Interface;
using System.Windows.Media.Animation;

namespace LitwareHR.PublicApp.WinUX
{
    /// <summary>
    /// Interaction logic for DefaultView.xaml
    /// </summary>
    public partial class DefaultView : System.Windows.Controls.UserControl, IDefaultView, IDisposable
    {
        /// <summary>
        /// Initialize a new instance of <see cref="DefaultView"/>.
        /// <summary>
        public DefaultView()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(OnLoad);
        }

        /// <summary>
        /// Called when WPF has loaded the control and is ready to display it.
        /// <summary>
        /// <param name="sender">Source of the event</param>
        /// <param name="e">Extra information about the event</param>
        void OnLoad(object sender, RoutedEventArgs e)
        {
            _presenter.OnViewReady();
        }

        /// <summary>
        /// This method is called after Schema has been synchronized
        /// It displays an alert "Schema Changed" and displays the same in the bottom panel
        /// </summary>
        public void NotifySchemaChanges()
        {
            tbSchemaChanged.Visibility = Visibility.Visible;
            imgSchemaChanged.Visibility = Visibility.Visible;
            Storyboard StoryboardSchemaChanged = (Storyboard)FindResource("StoryboardSchemaChanged");
            StoryboardSchemaChanged.Begin(rootCanvas, true);
        }

        /// <summary>
        /// This method is called when any(Data or Schema) Synchronization operation starts.
        /// This is used to Animate the "Synchronoization Icon" in the bottom panel
        /// </summary>
        public void StartSyncAnimation()
        {
            imgSync.Visibility = Visibility.Visible;
            tbSync.Visibility = Visibility.Visible;
            Storyboard storyboardRotation = (Storyboard)FindResource("StoryboardRotation");
            storyboardRotation.Begin(rootCanvas, true);
        }

        /// <summary>
        /// This method is called when Synchronization operation is completed
        /// This is used to stop Animation of "Synchronization Icon" and to hide it along with text (Synchronizing)
        /// </summary>
        public void EndSyncAnimation()
        {
            Storyboard storyboardRotation = (Storyboard)FindResource("StoryboardRotation");
            storyboardRotation.Stop(rootCanvas);
            Storyboard StoryboardEndSyncAnimation = (Storyboard)FindResource("StoryboardEndSyncAnimation");
            StoryboardEndSyncAnimation.Begin(rootCanvas);
        }

        public void LoadResources()
        {
            // Merge resoure directory
            base.Resources.MergedDictionaries.Add((ResourceDictionary)Application.LoadComponent(new Uri(@"Litware.HR;;;component/Views/Skins/BaseSkin.xaml", UriKind.Relative)));
        }
    }
}

